<?

define("EMAIL_NOT_FOUND", 1);

if (@$action == "do")
{
	require_once($r."_engine/c_account.php");
	require_once($r."_engine/functions.php");
	require_once($r."_engine/c_sp_gate.php");
	require_once($r."_site_struct.php");

	// Find account with specified e-mail address
	$a = new CAccount();
	if (!$a->LoadByEmail($f_login_email))
	{
		$status = EMAIL_NOT_FOUND;
	}
	else
	{
		// Send email to user with password
		$g_spg->SendEmail(array(
			"account_id"			=> $a->id,
			"email_content_type"	=> $a->data["def_alert_format"],
			"email_to"				=> $a->data["email"],
			"variables" => array(
				"first_name"		=> $a->data["first_name"],
				"password"			=> $a->data["password"],
				"login_url"			=> "http://".$g_site_root."/".$g_site_struct["login"]['l'],
			),
			"email_template_name"	=> "password_recovery",
		));

		generate_html_redirect("password_recovery_ack.php");
	}
}
?>